package api

import (
	"github.com/gin-gonic/gin"
	"server/global"
	"server/internal/middleware"
	"server/internal/model"
	"server/internal/pkg/response"
	"server/internal/services"
)

// UserBillApi 领取记录
var UserBillApi = new(userBillApi)

type userBillApi struct {
	model.UserBill
}

// Router 路由
func (a userBillApi) Router(r *gin.RouterGroup) {
	api := r.Group("/user_bill", middleware.LoginVerification, middleware.PermissionVerification)
	//验证权限
	api.GET("/list", a.list)
}

// List 列表
func (a userBillApi) list(c *gin.Context) {
	Db := global.GL_DB //初始化Db

	room_id := c.Query("room_id")
	if room_id != "" {
		Db = Db.Where("room_id = ?", room_id)
	}
	list, total := services.GetPagingList(Db, a, c, "user_id")

	response.SuccessList(c, list, total)
}
